/* 
 * Copyright [2018] [Alex/libo(liboware@gmail.com)]
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.infodb.gateway.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

import com.hyts.infodb.gateway.handler.GatewayViewHandler;
import com.hyts.infodb.context.SpringContextConfiguration;

import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

/** 
 * @author LiBo/Alex
 * @version V1.0 
 */
@Configuration
@Import(SpringContextConfiguration.class)
public class GatewayRouteConfiguration {
    
    @Bean
    public RouterFunction<ServerResponse> gatewayView() {
        return route(GET("/index"), GatewayViewHandler::index).andRoute(GET("/"),
                GatewayViewHandler::index).
                andRoute(GET("/Node/index"), GatewayViewHandler::nodeIndex).
                andRoute(GET("/Node/add"), GatewayViewHandler::nodeAdd).
                andRoute(GET("/Node/edit"),GatewayViewHandler::nodeEdit).
                andRoute(GET("/Node/refresh"), GatewayViewHandler::refresh);
    }
    
    /*@Bean
    public RouterFunction<ServerResponse> gatewayData() {
        return route(POST("/Node/doAdd"), GatewayDataHandler::save);
    }*/
}
